my $file = $ARGV[0];

open Input, "<$file" or die"cannot open $file\n";

$number = 0;
$firstline = 1;
$start = 0;
$end = 0;

$total = 0;
@seq[6000];
@rssi[6000];
@smooth[6000];
@smsmooth[6000];
while(<Input>){
	chomp;
	@rs = split;
	
	if($firstline==1){
		$seq[$total] = $rs[0];
		$rssi[$total] = $rs[1];
		$smooth[$total] = $rs[1];
		$smsmoothsmooth[$total] = $rs[1];
		$total++;
		$firstline=0;
	}
	else {
		$seq[$total] = $rs[0];
		$rssi[$total] = $rs[1];
		$smooth[$total] = ($rs[1] + $rssi[$total-1]) / 2;
		$smsmooth[$total] = ($rs[1] + $smooth[$total-1]) / 2;
		$total++;
	}
}
close Input;

$i=0;
open Output, ">testSmooth.log" or die "cannot open testSmooth.log\n";
while($i<$total) {
	print Output "$seq[$i]\t $rssi[$i]\t $smooth[$i]\t $smsmooth[$i]\n";
	$i++;
}
close Output;
